home *** CD-ROM | disk | FTP | other *** search
- VERSION 4.00
- Begin VB.Form frmSpy
- Caption = "The Spy Program"
- ClientHeight = 5910
- ClientLeft = 1215
- ClientTop = 945
- ClientWidth = 5325
- Height = 6600
- Icon = "SPY.frx":0000
- Left = 1155
- LinkTopic = "Form1"
- MaxButton = 0 'False
- ScaleHeight = 5910
- ScaleWidth = 5325
- Top = 315
- Width = 5445
- Begin VB.CheckBox chkReplaceKeyboardHits
- Caption = "Replace keyboard hits in Paintbrush with the letters: SPY SPY SPY..."
- Height = 255
- Left = 120
- TabIndex = 6
- Top = 5520
- Width = 5295
- End
- Begin VB.CheckBox chkBeep
- Caption = "Beep whenever someone double-clicks in Paintbrush"
- Height = 255
- Left = 120
- TabIndex = 5
- Top = 5160
- Width = 4215
- End
- Begin VB.Frame Frame1
- Caption = "Messages"
- Height = 615
- Left = 120
- TabIndex = 2
- Top = 4320
- Width = 3975
- Begin VB.OptionButton optAllMessages
- Caption = "All &Messages"
- Height = 320
- Left = 120
- TabIndex = 4
- Top = 240
- Value = -1 'True
- Width = 1225
- End
- Begin VB.OptionButton optOnlyDoubleClick
- Caption = "Only &Double-Click Message"
- Height = 320
- Left = 1560
- TabIndex = 3
- Top = 240
- Width = 2295
- End
- End
- Begin VB.Timer Timer1
- Interval = 200
- Left = 4440
- Top = 5040
- End
- Begin VB.TextBox txtMsg
- BeginProperty Font
- name = "Courier"
- charset = 0
- weight = 400
- size = 9.75
- underline = 0 'False
- italic = 0 'False
- strikethrough = 0 'False
- EndProperty
- Height = 4095
- Left = 120
- MultiLine = -1 'True
- TabIndex = 1
- Top = 120
- Width = 5055
- End
- Begin TegspyLib.TegoSpy TegoSpy1
- Height = 600
- Left = 4200
- TabIndex = 0
- Top = 4320
- Width = 930
- _version = 65536
- _extentx = 1640
- _extenty = 1058
- _stockprops = 0
- End
- Begin VB.Menu mnuFile
- Caption = "&File"
- Begin VB.Menu mnuExit
- Caption = "E&xit"
- End
- End
- Begin VB.Menu mnuHelp
- Caption = "&Help"
- Begin VB.Menu mnuAbout
- Caption = "&About..."
- End
- End
- Attribute VB_Name = "frmSpy"
- Attribute VB_Creatable = False
- Attribute VB_Exposed = False
- ' All variables must be declared.
- Option Explicit
- ' Declare general variables.
- Dim gMsg As String
- Private Sub Form_Load()
- TegoSpy1.Visible = False
- End Sub
- Private Sub mnuAbout_Click()
- Dim Title
- Dim Msg
- Dim CR
- CR = Chr(13) + Chr(10)
- ' The title of the About message box.
- Title = "About the Spy Program"
- ' Prepare the message of the About message box.
- Msg = "This program was written with Visual "
- Msg = Msg + "Basic for Windows, using the "
- Msg = Msg + "TegoSoft Spy OCX control. "
- Msg = Msg + CR + CR
- Msg = Msg + "The TegoSoft Spy OCX control "
- Msg = Msg + "is part of the TegoSoft OCX Control "
- Msg = Msg + "Kit - a collection of various OCX controls. "
- Msg = Msg + CR + CR
- Msg = Msg + "For more information about the "
- Msg = Msg + "TegoSoft OCX Control Kit, contact TegoSoft "
- Msg = Msg + "at:"
- Msg = Msg + CR + CR
- Msg = Msg + "TegoSoft Inc." + CR
- Msg = Msg + "P.O. Box 389" + CR
- Msg = Msg + "Bellmore, NY 11710"
- Msg = Msg + CR + CR
- Msg = Msg + "Phone: (516)783-4824"
- ' Display the About message box.
- MsgBox Msg, vbInformation, Title
- End Sub
- Private Sub mnuExit_Click()
- ' Terminate the program.
- Unload Me
- End Sub
- Private Sub TegoSpy1_MessageTrap()
- ' NOTE:
- ' This event procedure traps messagges that Windows
- ' sends to the currently running programs.
- ' Before a message is sent to the program that
- ' owns the message, this event procedure is
- ' executed.
- ' You can write code that analyzes the message
- ' and intercepts the message. That is, you can
- ' change the content of the message. For example,
- ' the sample code below, intercepts keyboard
- ' messages that are sent to Paintbrush, so that
- ' Paintbrush will always type the letters "S","P",
- ' "Y", whenever the user types anything in
- ' Paintbrush.
- ' Do NOT write code in this procedure that
- ' generates messages! For example, you must NOT
- ' write code in this procedure that changes the
- ' Caption or Text properties of the screen, of label controls, of Text
- ' controls or of any other controls. If you write
- ' code that generates messages in this procedure,
- ' then the system will be overloaded with messages.
- ' If you need to write code that displays text in
- ' this procedure, you can do it as follows:
- ' 1. Declare a general string variable in the
- ' General Declarations section of the form.
- ' 2. In this procedure, update the general string
- ' variable with the text that you want to display.
- ' 3. Place a timer control inside the form.
- ' 4. Attach code to the Timer event of the timer
- ' control that assigns the value of the general
- ' string variable to the Text property of the
- ' TextBox control.
- ' For example, this program uses a general string
- ' variable called gMsg. The code below assigns text
- ' to the gMsg variable. And the code inside the
- ' Timer1_Timer() procedure assigns the value of
- ' gMsg to the Text property of the txtMsg TextBox
- ' control.
- Dim ProgramName As String
- Dim ProgramIsPaintbrush As Boolean
- Static NumMessages As Integer
- Static CurrentLetter As String
- ' Get the Program name of the message.
- ProgramName = TegoSpy1.msgProgramWindowTitle
- ' Is the program name Paintbrush?
- If Left(ProgramName, 5) = "Paint" Or _
- Right(ProgramName, 5) = "Paint" Then
- ProgramIsPaintbrush = True
- ProgramIsPaintbrush = False
- End If
- ' If the Only Double-Click radio button is selected,
- ' or the message is Double-Click, we want to display
- ' the message. Otherwise, we don't want to display
- ' the message.
- If optOnlydoubleclick.Value = False Or _
- TegoSpy1.msgMessage = 515 Then
- ' Display the name of the program and the message.
- gMsg = gMsg + Left(ProgramName, 30)
- gMsg = gMsg + " - "
- gMsg = gMsg + Str(TegoSpy1.msgMessage)
- gMsg = gMsg + Chr(13) + Chr(10)
- ' Increment the NumMessages counter.
- NumMessages = NumMessages + 1
- ' If 20 messages are displayed, clear the messages
- ' text box, and reset NumMessages to 0.
- If NumMessages > 20 Then
- gMsg = ""
- NumMessages = 0
- End If
- End If
- ' If the chkBeep check box is checked,
- ' and the program name is Paintbrush, and the
- ' message is Double-Click, beep.
- If chkBeep.Value = 1 And _
- ProgramIsPaintbrush = True And _
- TegoSpy1.msgMessage = 515 Then
- Beep
- End If
- ' If the chkReplaceKeyboardHits check box
- ' is checked, and the program name is
- ' Paintbrush, and the user pressed any key on
- ' the keyboard, replace the ascii code of
- ' the pressed key with the letters "S", "P", "Y".
- If chkReplaceKeyboardHits.Value = 1 And _
- ProgramIsPaintbrush = True And _
- TegoSpy1.msgMessage = 258 Then
- If CurrentLetter = "S" Then
- CurrentLetter = "P"
- ElseIf CurrentLetter = "P" Then
- CurrentLetter = "Y"
- ElseIf CurrentLetter = "Y" Then
- CurrentLetter = " "
- Else
- CurrentLetter = "S"
- End If
- TegoSpy1.msgWParam = Asc(CurrentLetter)
- End If
- End Sub
- Private Sub Timer1_Timer()
- ' Update the txtMsg text box.
- txtMsg.Text = gMsg
- End Sub
-